//
//  DMNoDataView.m
//  新项目
//
//  Created by Gamin on 2016/12/23.
//  Copyright © 2016年 刘耀宗. All rights reserved.
//

#import "DMNoDataView.h"

@interface DMNoDataView ()

@end

@implementation DMNoDataView
@synthesize delegate = _delegate;

- (void)dealloc {
    _delegate = nil;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setViewAction];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)setViewAction {
    [_addAndAgainBut.layer setBorderWidth:1];
    [_addAndAgainBut.layer setBorderColor:[_contentLab.textColor CGColor]];
    [_addAndAgainBut.layer setMasksToBounds:YES];
    [_addAndAgainBut.layer setCornerRadius:_addAndAgainBut.frame.size.height/2.0];
    [self displayViewMark:1];
}

/**
 展示样式 默认为1
 1:暂无数据
 2:网络不好
 */
- (void)displayViewMark:(NSInteger)theMark {
    _addAndAgainBut.hidden = YES;
    if(theMark == 1){
        _markImgView.image = [UIImage imageNamed:@"ic_404_date.png"];
        _titleLab.text = @"啥都没有";
        _contentLab.text = @"请添加数据后再来~";
        [_addAndAgainBut setTitle:@"去添加" forState:UIControlStateNormal];
        _addAndAgainBut.tag = 4301;
        
    }else if(theMark == 2){
        _markImgView.image = [UIImage imageNamed:@"ic_404_date.png"];
        _titleLab.text = @"网络不好";
        _contentLab.text = @"请看看是否已经联网~";
        [_addAndAgainBut setTitle:@"再试试" forState:UIControlStateNormal];
        _addAndAgainBut.tag = 4302;
        _addAndAgainBut.hidden = NO;
    }
}


// 添加 & 再试试
- (IBAction)addAndAgainAction:(id)sender {
    UIButton *tempBut = (UIButton *)sender;
    if(tempBut.tag == 4301){
        [_delegate noDataTapAction:1];
    }else if (tempBut.tag == 4302){
        [_delegate noDataTapAction:2];
    }
}


@end
